package com.aplink.generic.pojo;

import java.io.Serializable;

import android.content.Context;
import android.text.TextUtils;

import com.aplink.generic.util.ResourcesHelper;

public class MasterConfig implements Serializable {
	private static final long serialVersionUID = -1314658575335273797L;
	private boolean hasOfflineMode;
	private boolean isDemo;
	private AutoSync mAutoSync;
	private int mAutoSyncInterval;
	private CloudNotification mCloudNotification;
	private String mDatabaseName;
	private String mDatabaseUpdateInfo;
	private int mDatabaseVersion = 1;
	private String mDemoData;
	private String mLoginClass;
	private String mMainMenu;
	private String mTableStructure;
	private int mTryTime = 1;
	private WebserviceConfig mWebserviceConfig;

	public MasterConfig() {
		this.mWebserviceConfig = new WebserviceConfig();
	}

	public AutoSync getAutoSync() {
		return this.mAutoSync;
	}

	/**
	 * 
	 * @return the auto sync interval. If the sync interval is not initialise,
	 *         return the default auto sync interval: 10 minutes.
	 */
	public int getAutoSyncInterval() {
		if (this.mAutoSyncInterval == 0) {
			return 10;
		}
		return this.mAutoSyncInterval;
	}

	public CloudNotification getCloudNotification() {
		return this.mCloudNotification;
	}

	public String getDatabaseName() {
		return this.mDatabaseName;
	}

	public String getDatabaseUpdateInfo() {
		return mDatabaseUpdateInfo;
	}

	public int getDatabaseVersion() {
		return this.mDatabaseVersion;
	}

	public String getDemoData() {
		return this.mDemoData;
	}

	public int getDemoDataID() {
		return ResourcesHelper.getRawIdByName(this.mDemoData);
	}

	public int getDemoDataID(final Context context) {
		return ResourcesHelper.getRawIdByName(context, this.mDemoData);
	}

	public String getLoginClass() {
		return this.mLoginClass;
	}

	public String getMainMenu() {
		return this.mMainMenu;
	}

	public int getMainMenuID() {
		if (TextUtils.isEmpty(this.mMainMenu)) {
			return ResourcesHelper.RESOURCE_NOT_FOUND;
		}
		return ResourcesHelper.getRawIdByName(this.mMainMenu);
	}

	public String getTableNameStructure() {
		return this.mTableStructure;
	}

	public int getTableNameStructureID() {
		return ResourcesHelper.getRawIdByName(this.mTableStructure);
	}

	public int getTableNameStructureID(final Context context) {
		return ResourcesHelper.getRawIdByName(context, this.mTableStructure);
	}

	public int getTryTime() {
		return this.mTryTime;
	}

	public WebserviceConfig getWebserviceConfig() {
		return this.mWebserviceConfig;
	}

	public boolean isDemo() {
		return this.isDemo;
	}

	public boolean isHasOfflineMode() {
		return this.hasOfflineMode;
	}

	public void setAutoSync(final AutoSync autoSync) {
		this.mAutoSync = autoSync;
	}

	public void setAutoSyncInterval(final int autoSyncInterval) {
		this.mAutoSyncInterval = autoSyncInterval;
	}

	public void setCloudNotification(final CloudNotification cloudNotification) {
		this.mCloudNotification = cloudNotification;
	}

	public void setDatabaseName(final String databaseName) {
		this.mDatabaseName = databaseName;
	}

	public void setDatabaseUpdateInfo(String databaseUpdateInfo) {
		mDatabaseUpdateInfo = databaseUpdateInfo;
	}

	public void setDatabaseVersion(final int databaseVersion) {
		this.mDatabaseVersion = databaseVersion;
	}

	public void setDemo(final boolean isDemo) {
		this.isDemo = isDemo;
	}

	public void setDemoData(final String demoData) {
		this.mDemoData = demoData;
	}

	public void setHasOfflineMode(final boolean hasOfflineMode) {
		this.hasOfflineMode = hasOfflineMode;
	}

	public void setLoginClass(final String loginClass) {
		this.mLoginClass = loginClass;
	}

	public void setMainMenu(final String mainMenu) {
		this.mMainMenu = mainMenu;
	}

	public void setTableStructure(final String tableStructure) {
		this.mTableStructure = tableStructure;
	}

	public void setTryTime(final int tryTime) {
		this.mTryTime = tryTime;
	}

	public void setWebserviceConfig(final WebserviceConfig webserviceConfig) {
		this.mWebserviceConfig = webserviceConfig;
	}
}
